/**
 * 
 */
package com.tien.dao;
/**
 * @author Tien  E-mail:g.tianxin@gmail.com
 * @version Time：2011-6-6 下午09:34:05
 */
import java.io.Serializable;
import java.util.Collection;
import java.util.List;

import org.hibernate.Criteria;
import org.hibernate.criterion.DetachedCriteria;

/**
 * @ClassName: IBaseDAO
 * @author xt40919
 * @version Create Time：Mar 29, 2011 2:14:09 PM
 */
public interface BaseDao<T,ID extends Serializable> {
    /**
     * Save Entity Object
     */
    public T saveEntity(T entity);
   
    /**
     * update Entity Object
     */
    public void updateEntity(T entity);
   
    /**
     * merge update Entity Object
     */
    public T mergeEntity(T entity);
   
    /**
     * Find Entity By Id
     */
    public T findById(Class<T> clazz,ID id);
   
   
    /**
     * HQL Select Entity List
     */
    public List<T> getEntitiesByHQL(String hql);
   
    /**
     *  Paging Entity List By HQL
     */
    public List<T> getEntitiesByHQL(String hql,Integer start,Integer limit);
   
   
    /**
     * Find Entity List By HQL with params
     */
    public List<T> getEntitiesByHQL(String hql,Object... argValues);
   
   
    /**
     * Paging Entity List By HQL with params
     */
    public List<T> getEntitiesByHQL( String hql,  Integer start, Integer limit, Object... argValues);
   
    /**
     * SQL Select Entity List
     */
    public List<T> getEntitiesBySQL(String sql,Class[] classes);
   
   
    /**
     * SQL Select Entity for Paging
     */
    public List<T> getEntitiesBySQL(String sql,Class[] classes,Integer start,Integer limit);
   
    /**
     *  SQL Select Entity List for paging with Params
     */
    public List<T> getEntitiesBySQL(String sql,Class[] classes,Object... argValues);
    /**
     * SQL分页查询符合条件的实例集合
     * SQL Select Entity List for paging with Params
     */
    public List<T> getEntitiesBySQL(String sql, Class[] classes, Integer start, Integer limit, Object... argValues);
   
    /**
     * HQL查询实例数
     * Select the Entities
     */
    public Long countEntitiesByHQL(String hql);
    /**
     * HQL查询符合条件的实例数
     * Select Entities with Params
     */
    public Long countEntitiesByHQL(String hql,Object... argValues);
   
    /**
     * HQL查询符合条件的实例
     * Select Entity By HQL
     */
    public Object findEntityByHQL(String hql,Object... argValues);
   
   
    /**
     * SQL查询符合条件的实例
     * select Entity By SQL
     */
    public Object findEntityBySQL(String sql,Class[] classes,Object... argValues);
   
    /**
     * HQL查询符合条件的实例
     * Select Entity BY HQL
     */
    public Object findEntityBySQL(String sql,Object... argValues);
   
    /**
     * HQL查询符合条件的实例数
     * Select Entities count By SQL with Params
     */
    public Long countEntitiesBySQL(String sql,Class[] classes);
   
    /**
     * HQL Select Entities By Sql with Params
     */
    public Long countEntitiesBySQL(String sql,Class[] classes,Object... argValues);

    /**
     *  Create the condition Criteria Object
     */
   
    public Criteria createCriteria(Class<T> clazz);
   
    /**
     *Delete One Entity
     */
    public void deleteEntity(T entity);
   
    /**
     * Delete All Entities
     */
    public void deleteEntities(Collection<T> collection);
   
   
   
    /**
     * Delete Entity By ID
     */
    public void deleteEntityById(Class<T> clazz,ID id);
   
    /**
     * 创建DetachedCriteria的查询
     * @author
     * @date
     * @param
     * @return
     */
    public Criteria createDetachedCriteria(DetachedCriteria detachedCriteria);
   
}

 